import json


class SqlInfo:
    def __init__(self, host: str, port: int, user: str, passwd: str, db: str):
        self.host = host
        self.port = port
        self.user = user
        self.passwd = passwd
        self.db = db


def config_read(file_path: str) -> list[SqlInfo]:
    sql_info_list = []
    with open(file_path) as f:
        config_list = json.load(f)

    for config_data in config_list:
        sql_info = SqlInfo(
            host=config_data["host"],
            port=config_data["port"],
            user=config_data["user"],
            passwd=config_data["passwd"],
            db=config_data["db"]
        )
        sql_info_list.append(sql_info)
    return sql_info_list


if __name__ == '__main__':
    config_read('../config.json')
